Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions: More granular access and Project Access page #877

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from

Conversation

martastain
Copy link
Member

@martastain martastain commented Oct 16, 2024

Conditional access to project settings tabs based on user permissions

ynput/ayon-backend#389 implements user/permission endpoints that return granular project permissions. Frontend should reflect these permissions and use this object instead of relying on isManager flags.

https://experimental.ayon.dev/docs#tag/Users/operation/get_current_user_permissions
https://experimental.ayon.dev/docs#tag/Users/operation/get_current_user_project_permissions

When the user is a manager, this object is returned accordingly (with all restrictions disabled)

This should (for now) be implemented only in the project settings page

Add Users page to Project settings

Add a new sub-page to project settings that would allow non-managers (but users with project.users write access) to add and remove users to the project (by assigning access groups to them).

  1. Original users page stays the same until we decide what to do with it.
  2. Users pages on project settings is called Users Projects
  3. Use single project selection on the left hand side to filter users by the project.
  4. Project selection also affects project access column to show for that project.
  5. Checkbox button in the toolbar that toggles to filtering by project. This is needed in order to see users with no project access, so they can be added to a project. The switch is called Filter by project access and is default off.
  6. Columns are username, full name, project access.
  7. We should only see users that are active=true.
  8. Right hand side should show selected user header with access summary for project and access groups table (full height).
  9. Feel free to rewrite all of this inspired by user settings.
  10. Use new SearchFilter bar for filtering of users.
  11. SearchFilter bar could filter by project which could remove need for 3. and 5.

Read only users

  • Access Groups table will need a read only mode.

This requires using a new set of endpoints, more information will be provided.

@martastain martastain linked an issue Oct 16, 2024 that may be closed by this pull request
@martastain martastain added type: feature Adding something new and exciting to the product sponsored This is directly sponsored by a client or community member labels Oct 16, 2024
@martastain martastain marked this pull request as draft October 17, 2024 14:26
@flynput flynput force-pushed the 872-ay-5074-top-level-permissions-for-normal-users branch from c9d93ef to ed4b0ca Compare October 22, 2024 07:17
@flynput flynput requested a review from Innders October 22, 2024 07:18
@flynput flynput force-pushed the 872-ay-5074-top-level-permissions-for-normal-users branch from e6801a9 to 251a48f Compare October 29, 2024 09:17
@Innders Innders changed the title Use user permissions to limit access to pages Permissions: More granular access and Project Access page Nov 8, 2024
Copy link
Member

@Innders Innders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Random gap here
    image

  • Admins/managers can't see Anatomy, Project Settings or Project Access
    image

@Innders Innders self-requested a review November 8, 2024 09:41
Copy link
Member

@Innders Innders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Site settings blocked
    image

  • I can land on anatomy tab even if I do not have access to it. I should be redirected to a page I have access to.
    image

  • Changing project management permissions seems to make no difference.
    image

@flynput
Copy link
Contributor

flynput commented Nov 11, 2024

@Innders pushed the latest changes, I realized there is one issue remaining: getting the list of users involved in the selected projects only considers the first project in the selection, that's because we cannot fetch user access groups for multiple projects at once. I would gladly use another endpoint that provides said information @martastain

@Innders
Copy link
Member

Innders commented Nov 11, 2024

we cannot fetch user access groups for multiple projects at once

The API may not allow it but we can definitely do it by looping over a single endpoint for different projects. Take a look a custom query -> https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#customizing-queries-with-queryfn

There are many examples in the codebase of this.

getProjectsInfo: build.query<GetProjectsInfoResponse, GetProjectsInfoParams>({
async queryFn({ projects = [] }, { dispatch, forced }) {
try {
// get project info for each project
const projectInfo: $Any = {}
for (const project of projects) {
// hopefully this will be cached
// it also allows for different combination of projects but still use the cache
const response = await dispatch(
getProjectApi.endpoints.getProjectAnatomy.initiate(
{ projectName: project },
{ forceRefetch: forced },
),
)
if (response.status === 'rejected') {
throw 'No projects found'
}
projectInfo[project] = response.data
}
return { data: projectInfo, meta: undefined, error: undefined }
} catch (error: $Any) {
console.error(error)
return { error, meta: undefined, data: undefined }
}
},
providesTags: (_res, _error, { projects }) =>
projects.map((projectName) => ({ type: 'project', id: projectName })),
}),

@Innders Innders self-requested a review November 11, 2024 10:35
Copy link
Member

@Innders Innders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User management access

  • For projects where there is no access, show greyed out in the table and sorted to the bottom.
  • Tabs are jumping around, they should be calculated based on permissions and stay consistent. Project selection should make no difference.

Project Access

  • Page padding
  • Page title Project access
  • Missing table titles
  • Only show active projects
  • User rows too heigh
  • Add shortcut to button (Shortcut Component)
  • Profile image 20px
  • Top right buttons, correct labels and remove shortcut
  • Context menu (I will create a mockup in figma)
  • Access groups width the same as middle table and weird padding on right
  • Toast not very descriptive “Operation successful”
  • Can’t scroll access groups
  • Resize access groups
  • Block double tapping “A” (or think of shortcuts that don’t conflict)
  • Shortcut needs to work when just hovering at the moment it only works once selected.
  • Empty place holder shouldn’t be table item.

Filtering

  • Project filtering doesn’t work
  • Text search doesn’t work
  • User options should not show admins, managers or services.
  • User filtering doesn’t filter users in access group tables.
  • If there is only once access group (from filtering or otherwise) adding should skip dialog and add them straight to that group.
  • Filtering access groups should also filter options in adding modal
  • Select/deselect all access groups

@flynput
Copy link
Contributor

flynput commented Nov 13, 2024

The following items were implemented, the ones missing are either in progress or need more feedback/discussion:

Tabs are jumping around, they should be calculated based on permissions and stay consistent. Project selection should make no difference.
Page padding
Page title Project access
Missing table titles
Only show active projects
User rows too high
Profile image 20px
Top right buttons, correct labels and remove shortcut
Context menu (no dynamic secondary context menu FTM)
Access groups width the same as middle table and weird padding on right
Toast not very descriptive “Operation successful”
Can’t scroll access groups
Empty place holder shouldn’t be table item.

User options should not show admins, managers or services.
User filtering doesn’t filter users in access group tables.
If there is only once access group (from filtering or otherwise) adding should skip dialog and add them straight to that group.
Filtering access groups should also filter options in adding modal
Select/deselect all access groups

@flynput
Copy link
Contributor

flynput commented Nov 14, 2024

Added new features to the list:
Add shortcut to button (Shortcut Component)
Block double tapping “A” (or think of shortcuts that don’t conflict)
Shortcut needs to work when just hovering at the moment it only works once selected.

Pending issues:

  • Resize access groups vertically - not sure how to do it
  • dynamic context menus

@Innders Innders marked this pull request as ready for review November 14, 2024 09:52
@Innders Innders self-requested a review November 14, 2024 12:41
Copy link
Member

@Innders Innders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project Settings

  • Add new project button is appearing when it shouldn’t. Home page and users settings page.
  • Add new project button showing when user does not have permissions.
  • If user does not have access at all to a project they should not see it in the list. (server issue)
  • Greyed out project row not working for project settings.
  • Greyed out project not visible for project access. (only works on anatomy)
  • Weird loading glitch

Project access

  • Border radius on panels
  • Gap at the top too big.
  • Gap too big between filter and titles
  • Users don’t see users (are you using graphql?)
  • Profile image is too big 26px not 20px.
  • User rows too high, they should be 32px as per figma.
  • Hover missing on edges for add button.
  • Rename no access column header Username -> User

Adding/Removing

  • When multiple selected, pressing A should add all.
  • Add more should use shortcut A
  • Add more dialog should show current groups selected
  • Add more not working?
  • Remove access button enabled when no user selected or non access user selected.
  • Context menu, ignore dynamic menu for now. Remove all access menu icon=remove_moderator.
  • Context menu, match figma text and icons.

Dialog

  • Select all no background, deselect uses prim container BG. No icon.
  • Item height should be 32px not 28px.
  • Keyboard controls: press enter to select/unselect.
  • Keyboard controls: Cmd/Ctrl + Enter to submit.
  • Keyboard controls: Cmd/Ctrl + A select all (bonus if easy)
  • Dialog max height 600px

Filtering

  • Project options show inactive projects.
  • Project text search not working.
  • User options should not show admins, managers or services.
  • Access Group, has value and has no value (bonus).
  • Prevent adding search options more than once.
  • Filters aren’t saving to user frontend preferences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsored This is directly sponsored by a client or community member type: feature Adding something new and exciting to the product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AY-5074 Top level permissions for normal users
3 participants